package com.bluestarenergy.party.sample.domain;

import java.io.Serializable;
import java.util.Date;

/**
 * Superclass of all entity classes.
 * 
 *            An entity is a class that has a unique identity and that does not
 * depend on the contents of its attributes to differentiate it. Entity class'
 * attributes may change over time but its identity won't change.
 * 
 *            Examples of entity classes include: Person, Check, Transaction, etc.
 * @version 1.0
 * @created 01-Sep-2006 11:55:32 AM
 */

public class BaseEntity implements Serializable {
	
	@Override
	public String toString() {
		return this.getClass().getCanonicalName() + " : ID=" + this.id;
	}
	/**
	 * Serial version
	 */
	private static final long serialVersionUID = 1L;

	/**
	 * Actor who created an instance of the entity class
	 */
	private String createdBy;
	/**
	 * When the entity class was created
	 */
	private Date dateCreated;
	/**
	 * Indicates when was the last date the entity class was changed
	 */
	private Date dateLastUpdated;
	/**
	 * Defines the unique identity of an entity class
	 */
	private Long id;
	/**
	 * Actor who last updated an instance of the entity class
	 */
	private String lastUpdatedBy;
	/**
	 * Determines the number of times an entity class has changed over time
	 */
	private Integer version;

	public BaseEntity(){

	}

	public String getCreatedBy(){
		return createdBy;
	}

	public Date getDateCreated(){
		return dateCreated;
	}

	public Date getDateLastUpdated(){
		return dateLastUpdated;
	}

	public Long getId(){
		return id;
	}

	public String getLastUpdatedBy(){
		return lastUpdatedBy;
	}

	public Integer getVersion(){
		return version;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setCreatedBy(String newVal){
		createdBy = newVal;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setDateCreated(Date newVal){
		dateCreated = newVal;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setDateLastUpdated(Date newVal){
		dateLastUpdated = newVal;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setId(Long newVal){
		id = newVal;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setLastUpdatedBy(String newVal){
		lastUpdatedBy = newVal;
	}

	/**
	 * 
	 * @param newVal
	 */
	public void setVersion(Integer newVal){
		version = newVal;
	}
	
	public boolean hasValidId()
	{
		return this.id!=null && this.id.longValue()>0;
	}
	public long getIdLong()
	{
		return this.id.longValue();
	}
}